angular.module('starter.controllers')
  .controller('itemNgIfPerformanceCtr', function ($scope, preData, $stateParams, $state, $q) {
    $scope.$on('$ionicView.loaded', () => {
      $scope.data = {};
      $scope.time = {};
      $scope.time.starTime = new Date();
      angular.copy($stateParams, $scope.data);
    });

    $scope.$on('$ionicView.beforeEnter', () => {
      $scope.time.endTime = new Date();
      $scope.time.difference = $scope.time.endTime.getTime() - $scope.time.starTime.getTime();
      console.info($scope.time);
    });

    $scope.back = () => {
      var obj = {};
      obj.difference = $scope.time.difference;
      obj.title = $scope.data.nums;
      obj.d2 = {};
      obj.d2 = $scope.time.difference;
      window.localStorage.setItem('key', angular.toJson(obj));
      $state.go('listPerformance');
    }
  });
